package protocol

import "encoding/json"

// Envelope 统一的消息协议（请求与响应都使用该格式）
type Envelope struct {
	Type       string          `json:"type"`
	RoomID     string          `json:"room_id,omitempty"`
	PlayerID   string          `json:"player_id,omitempty"`
	Payload    json.RawMessage `json:"payload,omitempty"`
	CreateTime int64           `json:"time,omitempty"`
}

// 常用消息类型（可根据业务继续扩展）
const (
	// 基础
	TypeHello       = "hello"
	TypeError       = "error"
	TypeUnknownType = "unknown_type"

	// 房间
	TypeJoinRoom      = "join_room"
	TypeJoined        = "joined"
	TypeLeaveRoom     = "leave_room"
	TypeLeft          = "left"
	TypeRoomBroadcast = "room_broadcast"
	TypeRoomMessage   = "room_message"
)
